package com.example.common.config;

import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class WebConfig implements  WebMvcConfigurer {

    @Resource
    private JwtInterceptor jwtInterceptor;

    // 加自定义拦截器JwtInterceptor，设置拦截规则
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtInterceptor).addPathPatterns("/**")
                .excludePathPatterns("/")
                .excludePathPatterns("/login")
                .excludePathPatterns("/register")
                .excludePathPatterns("/files/**")
                .excludePathPatterns("/notice/selectAll")
                .excludePathPatterns("/activity/selectById/**")
                .excludePathPatterns("/activity/selectTop")
                .excludePathPatterns("/activity/selectPage")
                .excludePathPatterns("/activity/updateReadCount/**")
                .excludePathPatterns("/weblog/**")
                .excludePathPatterns("/blog/selectById/**")
                .excludePathPatterns("/blog/selectAll")
                .excludePathPatterns("/blog/selectPage")
                .excludePathPatterns("/blog/selectTop")
                .excludePathPatterns("/blog/updateReadCount/**")
                .excludePathPatterns("/blog/selectRecommend/**")
                .excludePathPatterns("/category/selectAll")
                .excludePathPatterns("/comment/selectCount")
                .excludePathPatterns("/comment/selectForUser")
                .excludePathPatterns("/comment/selectForUser/**")
                .excludePathPatterns("/comment/selectById/**")
                .excludePathPatterns("/comment/selectPage")
                .excludePathPatterns("/comment/selectCount/**");
    }
}